export const getFormattedTimestamp = () => {
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0');
    const day = String(now.getDate()).padStart(2, '0');
    const hours = String(now.getHours()).padStart(2, '0');
    const minutes = String(now.getMinutes()).padStart(2, '0');
    const seconds = String(now.getSeconds()).padStart(2, '0');
    const milliseconds = String(now.getMilliseconds()).padStart(3, '0');

    return `${year}${month}${day}${hours}${minutes}${seconds}${milliseconds}`;
};

export const getNowDate = () => {
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0');
    const day = String(now.getDate()).padStart(2, '0');
    return `${year}-${month}-${day}`
};

/** 设置几天以后可选的日期 */
export const setDateLimit = (date: Date, days: number) => {
    const nowTime = new Date();
    nowTime.setHours(0,0,0,0);
    const sevenDaysLater = new Date(nowTime.getTime() + days * 24 * 60 * 60 * 1000);
    return date < sevenDaysLater;
};